/**
 * 流程环节
 */
$(function(){
	webUtils.nameSpace("wiseMen.flowRel");
	
	wiseMen.flowRel.add=function(grid,bt,gridDef){
		var q=gridDef.params.queryDatas;
		if(q.LCBH){
			var uuid=webUtils.uuid();
			//webUtils.topicSubscribe("form.afterBuild",wiseMen.scheduler.taskScheduler.afterFormBuild,true);
			var d=webUtils.dialog({
				url:ctx+"/dataModelDefAct/editTpl.do?dms=DM_FLOW_NODE_RELATION&DM_FLOW_NODE_RELATION_LCBH="+q.LCBH+"&winId="+uuid,
				onremove:function(){
					webUtils.topicPublish("dialog.close."+uuid,{uuid:uuid});
				}
			});
			webUtils.topicSubscribe("dialog.submit.success."+uuid,function(data){
				grid.bootstrapTable("refresh");
				d.close();
			},true);
		}else{
			webUtils.error("请选择流程");
		}
	}
	
	wiseMen.flowRel.mod=function(grid,rowIndex){
		var row = grid.bootstrapTable("getRowByIndex", rowIndex);
		var uuid=webUtils.uuid();
		
		//webUtils.topicSubscribe("form.afterBuild",wiseMen.scheduler.taskScheduler.afterFormBuild,true);
		var d=webUtils.dialog({
			url:ctx+"/dataModelDefAct/editTpl.do?dms=DM_FLOW_NODE_RELATION&DM_FLOW_NODE_RELATION_ID="+row.ID+"&winId="+uuid,
			onremove:function(){
				webUtils.topicPublish("dialog.close."+uuid,{uuid:uuid});
			}
		});
		webUtils.topicSubscribe("dialog.submit.success."+uuid,function(data){
			grid.bootstrapTable("refresh");
			d.close();
		},true);
		
	}
	
	wiseMen.flowRel.del=function(grid,rowIndex){
		var row = grid.bootstrapTable("getRowByIndex", rowIndex);
		webUtils.confirm("删除数据将不可恢复，是否继续！",function(r){
			if(r){
				$.post(ctx + "/formDataAction/delByIds.do", {tableName:"DM_FLOW_NODE_RELATION",ids: row.ID}, function (data) {
	                if (data.success) {
	                	grid.bootstrapTable("refresh");
	                } else {
	                	webUtils.error(data.msg);
	                }
	            }, 'json');
			}
		});
	}
	
	wiseMen.flowRel.view=function(grid,rowIndex){
		var row = grid.bootstrapTable("getRowByIndex", rowIndex);
		var uuid=webUtils.uuid();
		var d=webUtils.dialog({
			url:ctx+"/dataModelDefAct/viewTpl.do?dms=DM_FLOW_NODE_RELATION&DM_FLOW_NODE_RELATION_ID="+row.ID+"&winId="+uuid,
			onremove:function(){
				
			}
		});
	}
	
});